/*
 * @Author: xinyang3
 * @Date: 2021-03-05 03:36
 * @Descripttion: awesome description
 * @LastEditors: xinyang3
 * @LastEditTime: 2021-04-30 17:31
 */

(function ($) {
  var loaded = false;
  // targetPosition = $('.top').offset().top; // 滚动到锚点位置

  $('.middle').scroll(function (e) {
    var scrollTop = $(this).scrollTop(); // 滚动距离
    var scrollHeight = e.target.scrollHeight;
    var clientHeight = e.target.clientHeight;
    if (loaded) return;

    if (scrollTop + clientHeight >= scrollHeight - 50) {
      loaded = true;
      // require some modules and operation,eg
      var block = $('<p class="elem">other module code。。。</p>');
      console.log('element is loaded...');
      $(this).append(block);
    }
  });
  // 定时器
  // var mark = setInterval(() => {
  //   console.log(new Date());
  // }, 1000);

  function test(c, index) {
    console.log('c=${c},index=${index}');
  }
  for (let index = 0; index < 20; index++) {
    // (function (i) {
    var c = 123;
    test(c, index);
    // })(index);
  }

  $('.test1').on('click', function(e) {
    var a1 = 123;
    
    (function(b1){
      var c1 = 456;
      console.log(b1, c1);
    })(a1)  
  });

})(jQuery);
